﻿<?php
session_start();
$_SESSION['_code']=rand(1,9999);
require('conn.php');
//require('session.php');
require('functions.php');
//print_r($userdata);

//全站访问
if($config['fangwen']==4){
	exit('网站正在更新');
}	
//有效访问时间
if(is_numeric($config['ReadTime'])){
	$readtime=$config['ReadTime']*1000;
}else{
	$readtime=0;
}
$aid=guolv($_GET['aid']);//文章id
$uid=guolv($_GET['uid']);//用户id
$ip=GetIP();

//获取文章信息
if(is_numeric($aid)){
	$row=$mysql->query("select * from `rw` where `id` in({$aid}) limit 1");
	if($row){
		$data=$row[0];
		$_pic=str_replace('[weixin]','',$data['pic']);
		// if($data['pv_max']!==0 || $data['pv_max']!=='-1'){
			// if($data['pv']>=$data['pv_max']){
				// exit('文章已过期');	
			// }
		// }


		 
	}else{
		exit('文章已过期');	
	}
}else{
	_location($site,301);
	exit;
}

//访问限制
if($config['fangwen']=='2,5'){
		if(is_weixin()==false || is_QQ()==false){
			$long="{$site}/detail.php?uid={$uid}&aid={$aid}"; 
			echo "<title>{$data['title']}</title>";
			echo "<div style=\"height:0;overflow:hidden;\"><img src=\"http://img01.store.sogou.com/net/a/04/link?appid=100520031&w=710&url={$_pic}\"></div>";
			echo "<center><img src='http://qr.liantu.com/api.php?&bg=ffffff&fg=cc0000&text=".urlencode($long)."'><br />";	
			exit;//仅限微信、QQ访问
		}
}

if($config['fangwen']==1){
	if(is_mobile()==false){
		$long="{$site}/detail.php?uid={$uid}&aid={$aid}"; 
		echo "<title>{$data['title']}</title>";
		echo "<div style=\"height:0;overflow:hidden;\"><img src=\"http://img01.store.sogou.com/net/a/04/link?appid=100520031&w=710&url={$_pic}\"></div>";
		echo "<center><img src='http://qr.liantu.com/api.php?&bg=ffffff&fg=cc0000&text=".urlencode($long)."'><br />";
		exit;//仅限手机访问
	}
}

if($config['fangwen']==2){
		if(is_weixin()==false){
			$long="{$site}/detail.php?uid={$uid}&aid={$aid}"; 
			echo "<title>{$data['title']}</title>";
			echo "<div style=\"height:0;overflow:hidden;\"><img src=\"http://img01.store.sogou.com/net/a/04/link?appid=100520031&w=710&url={$_pic}\"></div>";
			echo "<center><img src='http://qr.liantu.com/api.php?&bg=ffffff&fg=cc0000&text=".urlencode($long)."'><br />";
			exit;//仅限微信访问		
		}
}

// setcookie("sdone");
// print_r($_COOKIE);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<title><?php echo $data['title']?></title>
<meta name="keywords" content="<?php echo $data['title']?>"/>
<meta name="description" content="<?php echo $data['title']?>"/>
<link rel="stylesheet" type="text/css" href="static/hz.css" media="all"><link href="Css1/header.css" rel="stylesheet" type="text/css" />
<link href="Css1/home.css" rel="stylesheet" type="text/css" /> <style>
            html, body{
                height: 100%;
                width:100%;
            }
            body{margin:0;font-family:"微软雅黑","Microsoft Yahei","Helvetica Neue",Helvetica,Arial,sans-serif;font-size:12px;overflow-x: hidden;color: #3a4049;height: 100%;background: #fff}
            body.withHeader {
                padding-top: 80px;
            }
            body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,blockquote,p {
                padding: 0;
                margin: 0;
            }*,*:before,*:after {
                 -webkit-box-sizing:border-box;
                 -moz-box-sizing:border-box;
                 box-sizing:border-box
             }
            .clear:before,.clear:after{
                content: " ";
                display: table;
            }
            input,select,textarea {
                outline: 0;
                background-color: #fff;
                border: 1px solid #D9D9D9;
                display: inline-block;
                padding: 5px 6px 3px;
                font-size: 12px;
                line-height: 20px;
                color: #555555;
                vertical-align: middle;
                resize: none;
            }
            em {
                font-style:normal;
                font-weight:normal;
            }
            img{max-width:100%;width:auto\9;height:auto;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}
            ol,ul,li {
                list-style-type:none;
                padding:0;
                margin:0;
            }
            ol,ul,li {
                list-style-type:none;
            }
            a {
                text-decoration:none;
                outline:none;
                color: #333;
                text-shadow:none;
                resize: none;
            }
            a:hover {
                outline:none;
                text-shadow:none;
            }
            div, input, select, textarea, span, img, table, td, th, p, a, button, ul, li,i {
                border-radius: 0 ;/*!important*/
                -moz-border-radius: 0;
                -webkit-border-radius: 0 ;
                outline:0 none;
            }
			/* 底部浮层 */
			.positionFooter {
				background: #f3f3f3;
				bottom: 0;
				left: 0;
				position: fixed;
				width: 100%;
				z-index: 200;
				border-top: 1px solid #ddd
			}
			.positionFooter li {
				float: left;
				position: relative;
				text-align: center;
				width: 33.3%;
				color: #3096c6;
				padding: 5px 0
			}
			.positionFooter li a {
				color: #8e8e8e;
				padding-top: 30px;
				font-size: 14px;
				display: block
			}
			.positionFooter li a.a1 {
				background: url(static/index/b1.png) no-repeat top center;
				background-size: 30px 27px
			}
			.positionFooter li a.a2 {
				background: url(static/index/b2.png) no-repeat top center;
				background-size: 30px 27px
			}
			.positionFooter li a.a3 {
				background: url(static/index/b3.png) no-repeat top center;
				background-size: 30px 27px
			}
            header{
                display: block;
                z-index: 999;
                overflow: hidden;
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
            }
            .top_bar{
                height: 44px;
                position: relative;
                background: rgba(255,50,50,.95);
            }
            .top_bar .abs_m {
                width: 100%;
                text-align: center;
                font-size: 20px;
                color: #fff;
                font-weight: bold;
                line-height: 44px;
            }
            .top_menu_bar{background:rgba(255,255,255,0.95);  height: 37px; }
            .top_menu{overflow:hidden; overflow-x:scroll; -webkit-overflow-scrolling:touch; }
            .top_menu::-webkit-scrollbar { display: none; }
            .top_menu_list {
                white-space: nowrap;
            }
            .top_menu_list .btn.cur {
                color: #d00;
                font-size: 15px;
                background: #ddd;
                border-radius: 20px;
            }
            .top_menu_list .btn {
                white-space: nowrap;
                display: inline-block;
                padding: 0 10px;
                color: #333;
                text-decoration: none;
                font-size: 14px;
                line-height: 26px;
                height: 26px;
                margin: 5px 0px 5px 5px;
                border-radius: 20px;
            }
			.btn-login {
				display: inline-block;
				width: 48%;
				height: 40px;
				border-radius: 3px;
				background: #B9B9B9;
				text-decoration: none;
				line-height: 39px;
				text-align: center;
				font-size: 17px;
				color: rgb(255, 255, 255);
			}			
            .list_content{-webkit-user-select:none;position: relative;}
            section{ border-top:1px solid #f0f0f0; position: relative; background-color: #fff}
            .list_content section:last-child{ border-bottom: 1px solid #f0f0f0; }
            section .article_link{ display:block; padding:10px 10px 10px 14px; text-decoration:none; -webkit-tap-highlight-color:rgba(0,0,0,.1); -webkit-touch-callout:none;}

            section h3{ color:#464646; font-size:17px; font-weight:normal; margin: 0; padding:0; line-height: 1.2em; text-align: justify;}
            .iphone section{ padding: 2px }
            .iphone section .article_link,
            .iphone section h3{ font-weight: bold;}
            .item_info{ font-size: 11px; line-height: 11px; margin-top: 10px; color: #999; position: relative; }
            section.middle_mode .article_link{ padding-right: 110px;}
            section.middle_mode h3{ min-height: 2.4em;}
            section.middle_mode .list_img_holder{ overflow: hidden; position: absolute; right: 10px; top:50%; margin-top: -31px;border-radius: 5px;}


            /* 信息流大图,中图,小图 */
            .list_img_holder{ background:url() #efefef no-repeat center center; background-size:54px; width:90px; height:63px;}
            .list_img_holder img{ border:none; display:block; width:100%; min-height:100%; -webkit-transition:opacity 300ms ease; -moz-transition:opacity ease .3s;  pointer-events: none}
            .list_img_holder_large img{border:none; display:block; width:100%; pointer-events: none}
            .list_img_holder_large_fix img{ position: absolute; }
            .list_image ul{ display:block; margin: 0; padding:0; list-style-type: none; }
            .list_image ul li{ display:inline-block; float:left; overflow:hidden; width:33.3%}
            .list_image ul li .list_img_holder{ margin:0 auto}
            .list_image ul li:first-child .list_img_holder{ float:left}
            .list_image ul li:last-child .list_img_holder{ float:right}

            @media screen and (min-width: 360px) {
              section h3{ font-size:19px;}
              section.middle_mode h3 {min-height: 54px;}
              .list_img_holder{width:106px; height:73px;}
              section.middle_mode .list_img_holder{ margin-top: -36px}
              section.middle_mode .article_link{ padding-right: 130px;}
            }

            @media screen and (min-width: 400px) {
              section h3{ font-size:21px;}
              section.middle_mode h3 {min-height: 58px;}
              .list_img_holder{width:114px; height:80px;}
              section.middle_mode .list_img_holder{ margin-top: -40px }
              section.middle_mode .article_link{ padding-right: 135px }
            }

            @media screen and (min-width: 700px) {
              section h3{ font-size:24px}
              .list_img_holder{width:203px; height:140px;}
              section.middle_mode .list_img_holder{ margin-top: -70px }
              section.middle_mode .article_link{ padding-right: 230px }
              section.middle_mode h3{ min-height: 120px}

              section .media_avatar img{ width: 96px; height: 96px;}
              section .media_info h3{ font-size: 22px;  margin-bottom: 10px;}
            }
            .item_info span{margin-right: 5px;opacity: .75}
            #more-loading{ border-top:1px solid #f0f0f0;background-color: #fff}
            #more-loading a{text-align:center;font-size: 16px;;display:block; padding:10px 10px 10px 14px; text-decoration:none; -webkit-tap-highlight-color:rgba(0,0,0,.1); -webkit-touch-callout:none;}
            .nothing{text-align: center;padding:20px 10px;font-size: 20px;color:#999}
            .nothing i{color:#bbb;opacity: .5}

.g-header {
  width: 100%;
  height: 47px;
  border-bottom: 1px solid #ccc;
  background: #fff;
  z-index: 20;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}.g-header-logo {
  display: block;
  float: left;
  width: 80px;
  height: 40px;
  margin-left: 10px;
  margin-top: 2px;
}
        </style> <script src="jquery.js"></script>
 <script src="webuploader.js"></script>

<style type="text/css">
body.mWrap {
    padding: 1.2em;
    overflow: hidden;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
}.mWrap {
    width: 100%;
    height: 100%;
    margin: 0 auto;
}body {
    font: 14px/1.5 "Microsoft Yahei";
    font-size: 62.5%;
    color: #333;
    background: #e4e4e4;
}.cttBg {
    padding: 0.8em 1.5em;
    background: #fff;
}.cttBg .form {
    font-size: 1.45em;
}
.form {
    margin: 0 0 0.5em;
    font-size: 1.68em;
    width: 100%;
}.form li {
    margin-bottom: 0.5em;
    width: 100%;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
}.cttBg .form li:first-child span {
    font-weight: bold;
    font-size: 1.1em;
}
.blue {
    color: #0073c3;
}.form li {
    margin-bottom: 0.5em;
    width: 100%;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
}.webuploader-container {
	position: relative;
}
.webuploader-element-invisible {
	position: absolute !important;
	clip: rect(1px 1px 1px 1px); /* IE6, IE7 */
    clip: rect(1px,1px,1px,1px);
}
.webuploader-pick {
	position: relative;
	display: inline-block;
	cursor: pointer;
	background: #00b7ee;
	padding: 10px 15px;
	color: #fff;
	text-align: center;
	border-radius: 3px;
	overflow: hidden;    width: 100%; margin-top:20px
}
.webuploader-pick-hover {
	background: #00a2d4;
}

.webuploader-pick-disable {
	opacity: 0.6;
	pointer-events:none;
}
.uploader .thumbnail {
    width: 25%;
    max-height: 100px;
}
.file-item {
    float: left;
    position: relative;
 
    margin-top: 10px;
}  .btn {
    width: 100%;
    height: 2.64em;
    line-height: 2.64em;
    text-align: center;
    font-size: 1.11em;
    color: #fff;
    border: 0 none;
    cursor: pointer;
    background: #F9873C;
}  .thumbnail img {
    width: 95%;
    height: 100px;
    
}
</style>

</head>
<body class="mWrap">
<?php
 
 if($_POST){
	 
	 

	 
	 $title=guolv($_POST['title']);
 $nr=guolv($_POST['sm']);
 $photo1=guolv($_POST['photo1']);
 $photo2=guolv($_POST['photo2']);
  $photo3=guolv($_POST['photo3']);
   $photo4=guolv($_POST['photo4']);
    $user=$_SESSION['userdata']['id'];
  $rwuser=guolv($_POST['rwuser']);
 
 

 
 
 
 
 $row=$mysql->query("select * from `rwsh` where `user` in({$user})  and `rwid` ={$aid}  limit 1");
	if(!$row){
		
		
 
 
 if($user!=''){
 
	$mysql->query("insert into `rwsh` values(null,'{$title}','{$photo1}','{$photo2}','{$photo3}', '{$photo4}','{$user}','{$nr}',0,now(),{$aid},{$data['money']},$rwuser,0)");
 
$id=mysql_insert_id();
 
  $mysql->execute("update `rw` set  `cy`=cy+1  where `id`='{$aid}'");
 

if($id!==0){
	echo "<script>alert('参与成功！');location.href='mylist.php'</script>";
	}
	exit;
	}



}else{
	
	echo "<script>alert('您已经参加过此次任务！');location.href='mylist.php'</script>";
	}


}



?>
 <form action="" method="post"><?php include('header.php');?>
<section class="mContent" style=" margin-top:40px;">
		<article class="cttBg">
			<ul class="form">
				<li>
				 
				<span class="blue"><?php echo $data['title']?></span></li>
				<li>佣金：<?php echo $data['money']?></li>
				<li>结束时间：<?php echo $data['day']?></li>
				 <li>剩余：<?php echo $data['rs']-$data['cy']?> 人</li>
			 
			</ul>
		</article>
 
	</section>
  <input name="title" type="hidden" value="<?php echo $data['title']?>">
         <input name="rwid" type="hidden" value="<?php echo $aid?>">
          <input name="rwuser" type="hidden" value="<?php echo $data['userid']?>">
	 
    <section class="mContent"  style="margin-top:20px">
		<article class="cttBg">
			<ul class="form">
				<li >
				 
			<?php echo $data['content']?></li>
				 
			 
			</ul>
		</article>
 
	</section>   
   
		          <?php
    
    	 if($data['cy']<$data['rs']){
		 
		 
		 
		 ?>
   <?php 
    if(strtotime($data['day'])>strtotime(date("Y-m-d"))){
		
		?>   

 

   <section class="mContent"  style="margin-top:20px">
			<li><input  type="submit" class="btn" value="参与任务"  ></li>
	</section>
	 <?php
    }
	}?></form><?php 
 
$mysql->__destruct();
$mysql->close();
?>
</body>
</html>
